/*
 * Copyright (c) 2010 Curtis Boyden.  All rights reserved. 
 * This software was developed by Curtis Boyden and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is ejMud
 * (Ewerp Java MUD).  The Initial Developer is Curtis Boyden.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.
 */

package com.ewerp.mud;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BaseMockObject implements IBaseMockObject {    
    private Map<String, List<Object[]>> methodInvocations = new HashMap<String, List<Object[]>>();
    
    public void addMethodInvocation(String methodName, Object[] methodParameters) {
        synchronized(methodInvocations) {
            if (!methodInvocations.containsKey(methodName)) {
                methodInvocations.put(methodName, new ArrayList<Object[]>());
            }

            methodInvocations.get(methodName).add(methodParameters);
        }
    }
    
    @Override
    public int getMethodInvocationCount(String methodName) {
        int invocationCount = 0;
        synchronized(methodInvocations) {
            List<Object[]> parametersList = methodInvocations.get(methodName);
            if(parametersList != null) {
                invocationCount = parametersList.size();
            }
        }
        return invocationCount;
    }
    
    @Override
    public List<Object[]> getMethodInvocationParameters(String methodName) {
        List<Object[]> parametersList = null;
        synchronized(methodInvocations) {
            parametersList = methodInvocations.get(methodName);
        }
        return parametersList;
    }
    
}
